# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=trigger-rally
pkgver=0.6.7
pkgrel=2
pkgdesc="Fast-paced free software rally racing game"
url="https://trigger-rally.sourceforge.io/"
arch="all"
license="GPL-3.0-or-later"
depends="$pkgname-data"
makedepends="sdl2-dev sdl2_image-dev freealut-dev physfs-dev glew-dev tinyxml2-dev openal-soft-dev"
subpackages="$pkgname-doc $pkgname-data::noarch"
options="!check" # No testsuite
source="
	https://sourceforge.net/projects/aat-linux-repository/files/sources/alpine/trigger-rally/trigger-rally-$pkgver.tar.gz
	0001-fix-sdl2-detection.patch
	trigger-rally.desktop
	"
builddir="$srcdir/$pkgname-$pkgver/src"
_datadir="$srcdir/$pkgname-$pkgver/data"

build() {
	make -f GNUmakefile \
		exec_prefix=/usr \
		bindir=/usr/bin \
		prefix=/usr \
		OPTIMS=""
}

package() {
	make install \
		DESTDIR="$pkgdir" \
		exec_prefix=/usr \
		bindir=/usr/bin \
		prefix=/usr \
		OPTIMS=""

	# Remove residual files not needed for installation
	rm -r $pkgdir/usr/share/applications
	rm -r $pkgdir/usr/share/metainfo

	# Install desktop file
	install -Dm644 "$srcdir"/trigger-rally.desktop \
	"$pkgdir"/usr/share/applications/trigger-rally.desktop

	# Install icons
	install -Dm644 $_datadir/icon/trigger-16.png \
	"$pkgdir/usr/share/icons/hicolor/16x16/apps/trigger-rally.png"

	install -Dm644 $_datadir/icon/trigger-32.png \
	"$pkgdir/usr/share/icons/hicolor/32x32/apps/trigger-rally.png"

	install -Dm644 $_datadir/icon/trigger-64.png \
	"$pkgdir/usr/share/icons/hicolor/64x64/apps/trigger-rally.png"

	install -Dm644 $_datadir/icon/trigger-rally-icons.svg \
	"$pkgdir/usr/share/icons/hicolor/scalable/apps/trigger-rally.svg"

	install -Dm644 $_datadir/icon/trigger-64.png \
	"$pkgdir/usr/share/pixmaps/trigger-rally.png"

	install -Dm644 $_datadir/icon/trigger-rally.appdata.xml \
	"$pkgdir"/usr/share/metainfo/trigger-rally.appdata.xml

	# Move config
	mv "$pkgdir"/usr/bin/trigger-rally.config.defs \
	"$pkgdir"/usr/share/games/trigger-rally/trigger-rally.config.defs
}

data() {
	pkgdesc="$pkgdesc (data files)"
	amove /usr/share/games/trigger-rally
}

sha512sums="
e9324cf2b461a040a061a7e6dbcf29f600dc6a637e11a166efa0d74e47e16f1bd4ec5faddd253a9d5be3bb9a1ebfea790183826d9f056b38647ef287b25186cf  trigger-rally-0.6.7.tar.gz
2150afa09ff0080388fdc4b6c6adc173ae765884e75fab18aa8ce2614f0aab7bba03eb45ee4c4845c58d0498bde4e0723adb1c41ec53ab98fabee1405f982145  0001-fix-sdl2-detection.patch
14dbf1fa47de53b86ca66ba81c5c47543201b15e5bb5269f99ed80e5e143d3aa6e5bd35a3ca666019d919737e8324bd1756f4a6d7f55a6b9826be454a92e0759  trigger-rally.desktop
"
